package com.ctbri.manage.quality.scala.original
import com.ctbri.manage.quality.config.YamlReader

import java.util
import com.amazon.deequ.checks.Check

import java.lang.reflect
import scala.collection.JavaConverters._
import lombok.Getter
import lombok.Setter
import org.yaml.snakeyaml.Yaml

import java.io.{File, FileInputStream}
/**
 * @author songyunlong
 * @createTime 2023/6/5 14:36
 * @description
 */
case class ConfigReader(configPath: String, dataSource: String){
    def getConfigMap(): util.Map[String, util.HashMap[String, Any]]={
        YamlReader.getInstance(this.configPath).setConfForScala(new Yaml().load(new FileInputStream(new File(this.configPath))).asInstanceOf[util.Map[String, AnyRef]])
        val conf = YamlReader.getInstance(this.configPath).getConfForScala
        println("check functions parameters:")
        conf.forEach((key, value)=>println(key + ": " + conf.get(key)))
        //获取需要执行的功能名和功能所需要的参数名
        YamlReader.getInstance(this.configPath).get2dMap("checkFunces")
    }
}

object ConfigReader{
    def apply(configPath: String, dataSource: String): ConfigReader = new ConfigReader(configPath=configPath, dataSource=dataSource)
    def main(args: Array[String]): Unit ={
        ConfigReader(configPath="/Users/songyunlong/Desktop/data-manage/data-quality/src/main/resources/config/sub/deequConfig.yaml",
            dataSource="excel").getConfigMap()
    }
}
